package LeetCode.NumOffer;

/**
 * 反转链表
 * @author lumin
 * @date 2022/03/17 17:13
 **/
public class NumOffer24 {
    public class ListNode {
       int val;
       ListNode next;
       ListNode(int x) { val = x; }
    }
    public ListNode reverseList(ListNode head) {
        if(head == null){
            return null;
        }
        if(head.next == null){
            return head;
        }
        ListNode newHead = reverseList(head.next);
        head.next.next = head.next;
        head.next = null;
        return newHead;
    }
}